import  Mock  from "mockjs";
// 登录接口
Mock.mock('/api/login','post',(res)=>{
    let phone=JSON.parse(res.body).phone
    let reg=/^1[0-9]{10}$/
    if(reg.test(phone) && res.body.phone!=''){
        if(phone){
            return{
                code:0,
                msg:'登录成功',
                phone
            }
        }else{
            return{
                code:1,
                msg:'登录失败'
            }
        }
    }
})
Mock.mock('/api/auth','post',(res)=>{
    let auth=JSON.parse(res.body).authPhone
    let num=''
    for(let i=0;i<4;i++){
        num+=Math.floor(Math.random()*10)
    }
    if(auth){
        return {
            code:0,
            msg:'验证码发送成功',
            auth:num
        }
    }else{
        return {
            code:1,
            msg:'验证码发送失败',
        }
    }
})